package com.lancoo.ccas52.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lancoo.ccas52.entity.Student;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lancoo.ccas52.entity.TeachingClassStudent;
import com.lancoo.ccas52.pojo.common.PageInfo;
import com.lancoo.ccas52.pojo.response.basicPlatform.BaseStudent;
import com.lancoo.ccas52.pojo.vo.*;
import com.lancoo.ccas52.util.ResponseObject;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 学生 服务类
 * </p>
 *
 * @author quin.song
 * @since 2023-01-05
 */
public interface StudentService extends IService<Student> {

    /**
     * 根据教学班id获取学生
     * @param page
     * @param teachingClassId
     * @return
     */
    PageInfo<Student> getStudentsByTeachingClassId(IPage page,Long teachingClassId);

    /**
     * 根据课程id,修读性质获取已选学生列表
     * @param page
     * @param flag
     * @param courseId
     * @param studyNature
     * @param teachingClassType
     * @return
     */
    PageInfo<Student> getStudentsCourse(IPage page,Integer flag, Long courseId, Integer studyNature, Integer teachingClassType);

    /**
     * 根据修读性质 课程id获取教学班人数
     * @param flag
     * @param courseId
     * @param studyNature
     * @return
     */
    int getStudentCountByCourse(Integer flag, Long courseId, Integer studyNature,Integer teachingClassType);
    /**
     * 根据基础平台id/学号获取学生详情
     * @param taskId
     * @param baseStudentId
     * @return
     */
    Student getStudentByBaseStudentId(Integer taskId,String baseStudentId);

    /**
     * 判断学生是否是禁选学生
     * @param studentId
     * @return
     */
    boolean isProhibitStudent(Long studentId);
    /**
     * 条件获取全部学生
     * @param taskId
     * @param page
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param classId
     * @param keyWord
     * @return
     */
    PageInfo<Student> getStudentByConditions(Integer taskId,IPage page,String collegeId,String majorId,String gradeId,String classId,String keyWord,Integer selectionScope);


    /**
     * 通过plan_teaching_student表获取学生选课上限列表
     * @param taskId
     * @param page
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param studyNature
     * @param keyWord
     * @param state
     * @return
     */
    PageInfo<Student> getStudentJoinLimit(Integer taskId,IPage page,String collegeId,String majorId,String gradeId,Integer studyNature,String keyWord,Integer state);

    /**
     * 获取禁选学生列表
     * @param cssTaskId
     * @param page
     * @param collegeId
     * @param gradeId
     * @param keyWord
     * @return
     */
    PageInfo<StudentProhibitVo> getProhibitStudent(Integer cssTaskId,IPage page,String collegeId,String gradeId,String keyWord);

    /**
     * 更新学生 - 可选专业
     * @param studentIds
     * @param selectionScope
     * @return
     */
    Boolean updateStudent(List<Long> studentIds,Integer selectionScope);

    /**
     * 获取[在线选课]退选学生列表信息
     * @param taskId
     * @param page
     * @param collegeId
     * @param majorId
     * @param gradeId
     * @param classId
     * @param keyWord
     * @return
     */
    PageInfo<StudentCourseVo> getDeselectStudent(Integer taskId,IPage page,String collegeId,String majorId,String gradeId,String classId,String keyWord);

    /**
     * 根据学生id获取已选课程
     * @param studentId
     * @param teachingClassType
     * @return
     */
    List<StudentTeachingClass>  getSelectedByStudentId(Integer taskId, Long studentId, Integer teachingClassType);

    /**
     * 获取学生选课要求
     * @param taskId
     * @param studentId
     * @param studyNature
     * @return
     */
    SelectionRequireVo getSelectionRequire(Integer taskId, Long studentId, Integer studyNature);


    /**
     * 获取学生可选的教学班课程
     * @param taskId
     * @param currentPage
     * @param pageSize
     * @param studentId
     * @param teachingClassType
     * @param courseTypeId
     * @param courseNature
     * @param credit
     * @param studyNature
     * @param keyWord
     * @param isExist
     * @return
     */
    PageInfo<StudentTeachingClass> getAvailableTeachingClass(Integer taskId, Integer currentPage, Integer pageSize, Long studentId, Integer teachingClassType, String courseTypeId, Integer courseNature, Double credit, Integer studyNature, String keyWord, Integer isExist, Integer roundId);

    /**
     * 获取学生可选的教学班课程 已选教学班 选课要求
     * @param getAvailableCondition
     * @return
     */
    StudentTeachingClassView getAvailableTeachingClass(GetAvailableCondition getAvailableCondition);


    /**
     * 获取学生 无需选课的课程 环节教学班
     * @param taskId
     * @param studentId
     * @return
     */
    List<StudentTeachingClass> getNormalTeachingClass(Integer taskId, Long studentId);
    /**
     * 学生选课 lua脚本实现
     * @param addSelectCourse
     * @return
     */
    int selectCourseOptimize(AddSelectCourse addSelectCourse);

    /**
     * 学生选课
     * @param taskId
     * @param studentId
     * @param teachingClassId
     * @return
     */
    int selectCourse(Integer taskId, Long studentId, Long teachingClassId,Long cancelTeachingClassId);

    /**
     * 学生退选 lua脚本实现
     * @param addCancelCourse
     * @return
     */
    int cancelCourseOptimize(AddCancelCourse addCancelCourse);
    /**
     * 退选
     * @param taskId
     * @param studentId
     * @param teachingClassId
     * @param flag  2退选   3管理员移除
     * @return
     */
    int cancelCourse(Integer taskId, Long studentId, Long teachingClassId,Integer flag);

    /**
     * 判断是否选择该课程
     * @param taskId
     * @param studentId
     * @param teachingClassType
     * @param studyNature
     * @param courseId
     * @return
     */
    StudentTeachingClass isExistSelectCourse(Integer taskId, Long studentId, Integer teachingClassType,Integer studyNature, Long courseId);

    /**
     * 批量设置教学班学生<只在线选课使用>
     * @param batchSetStudent
     * @return
     */
    List<TeachingClassStudent>  batchAddStudent(BatchSetStudent batchSetStudent);

    /**
     * 同步redis选课数据
     * @param taskId
     */
    Boolean syncTeachingClassStudent(Integer taskId);


    Boolean clearCacheByTeachingClass(Integer taskId, Long courseId, Integer studyNature, Long teachingClassId);



    void syncBaseStudent(Integer taskId, List<BaseStudent> baseStudents,List<String> gradeList);

    /**
     * 导出退选学生
     * @param taskId
     * @param collegeId
     * @param collegeName
     * @param majorId
     * @param majorName
     * @param gradeId
     * @param gradeName
     * @param classId
     * @param className
     * @return
     */
    String deselectStudentToExcel(Integer taskId, String collegeId, String collegeName, String majorId,String majorName,String gradeId,String gradeName,String classId,String className);

}
